#ifndef _SDLENGINE_H
#define	_SDLENGINE_H

#include <SDL/SDL_syswm.h>
#include <SDL/SDL.h>

class SDLEngine {
private:
    long m_lLastTick;
    int m_iWidth;
    int m_iHeight;
    bool m_bQuit;
    const char* m_czTitle;
    SDL_Surface* m_pScreen;
    bool m_bMinimized;
    int m_iFPSTickCounter;
    int m_iFPSCounter;
    int m_iCurrentFPS;
    int m_uiMaxFPS;
    bool m_bFullscreen;

protected:
    void DoThink();
    void DoRender();
    void SetSize(const int& iWidth, const int& iHeight, bool bFullscreen);
    void HandleInput();

public:
    SDLEngine();
    virtual ~SDLEngine();

    void Init();
    void Start();
    void Stop();
    void ToggleFullscreen();

    virtual void AdditionalInit() = 0;
    virtual void Think(const int& iElapsedTime) = 0;
    virtual void Render(SDL_Surface* pDestSurface) = 0;
    virtual void End() = 0;
    virtual void WindowActive() = 0;
    virtual void WindowInactive() = 0;
    virtual void KeyUp(const int& iKeyEnum) = 0;
    virtual void KeyDown(const int& iKeyEnum) = 0;
    
    virtual void MouseMoved(const int& iButton,
            const int& iX,
            const int& iY,
            const int& iRelX,
            const int& iRelY) {
    }

    virtual void MouseButtonUp(const int& iButton,
            const int& iX,
            const int& iY,
            const int& iRelX,
            const int& iRelY) {
    }

    virtual void MouseButtonDown(const int& iButton,
            const int& iX,
            const int& iY,
            const int& iRelX,
            const int& iRelY) {
    }

    void SetTitle(const char* czTitle);
    void SetMaxFPS(unsigned int uiMaxFPS);
    const char* GetTitle();

    SDL_Surface* GetSurface();

    int GetFPS();
};

#endif	/* _SDLENGINE_H */

